<template>
    <div class="real-name">
        <div class="bg">
            <div class="content">
                <img src="@/assets/images/authentication.png">
                <div class="detail">
                    <span class="title">实名认证安全保障</span>
                    <span class="text">为保证您的资金安全，亲填写与您身份一致的信息，否则不会通过认证</span>
                </div>
            </div>
        </div>
        <div class="container">
            <div class="person-info">
                <span class="info bold">填写个人信息</span>
                <div class="name">
                    <span class="f14">您的姓名</span>
                    <input type="text" v-model="name" placeholder="请输入真实的姓名">
                </div>
                <div class="card-number">
                    <span class="f14">身份证号</span>
                    <input type="number" v-model="cardNumber" maxlength="18" placeholder="请输入身份证号">
                </div>
                <span class="upload bold">上传证件</span>
                <div class="upload-file">
                    <div class="item">
                        <div class="reverse">
                            <input type="file" accept="image/png, image/jpeg, image/jpg" @change="reverseUpload">
                            <img v-if="reverseSrc" :src="reverseSrc">
                            <img v-else src="@/assets/images/ID-card1.png">
                        </div>
                        <span class="f12">上传身份证人图像</span>
                    </div>
                    <div class="item">
                        <div class="front">
                            <input type="file" accept="image/*" @change="frontUpload">
                            <img v-if="frontSrc" :src="frontSrc">
                            <img v-else src="@/assets/images/ID-card2.png">
                        </div>
                        <span class="f12">上传身份证国徽面</span>
                    </div>
                </div>
                <div class="warning">
                    <img src="@/assets/images/warn1.png">
                    <span class="text f12">证件文字需要清晰辨认，无遮挡或模糊</span>
                </div>
            </div>
        </div>
        <div class="done">
            完成认证
        </div>
    </div>
</template>
<script>

export default {
    name: "",
    data() {
        return {
            name: "",
            cardNumber: "",
            reverseSrc: "",
            frontSrc: "",
        }
    },
    methods: {
        reverseUpload(event) {
            const data = event.target.files[0];
            if (data)
                this.reverseSrc = URL.createObjectURL(event.target.files[0])
        },
        frontUpload(event) {
            const data = event.target.files[0];
            if (data)
                this.frontSrc = URL.createObjectURL(event.target.files[0])
        }
    }
}
</script>
<style lang="scss" scoped>
.real-name {
    min-height: 100vh;
    background-color: #f7f7f7;

    .bg {
        background-image: linear-gradient(to right, #fe5447, #fb132b);
        height: 220px;
        padding: 0 15px;
        overflow: hidden;

        .content {
            display: flex;
            margin-top: 40px;

            .detail {
                display: flex;
                flex-direction: column;
                color: white;

                .title {
                    font-size: 20px;
                    margin-bottom: 10px;
                }

                .text {
                    font-size: 14px;
                }
            }

            img {
                width: 60px;
                margin-right: 15px;
                object-fit: contain;
            }
        }
    }

    .container {
        padding: 0 15px;
        background-color: #f7f7f7;

        .person-info {
            transform: translateY(-80px);
            border-radius: 15px;
            padding: 20px 25px;
            background-color: white;

            .info {
                margin-bottom: 20px;
            }

            .name,
            .card-number {
                padding: 15px 0;
                border-bottom: 1px solid #e5e5e5;

                span {
                    margin-right: 20px;
                }

                input {
                    border: 0;
                    outline: 0;

                    &::placeholder {
                        font-size: 14px;
                    }
                }
            }

            .upload {
                margin-top: 25px;
            }

            .upload-file {
                display: flex;
                flex-direction: row;
                justify-content: space-between;
                margin-top: 10px;

                .item {
                    width: 47%;
                    text-align: center;

                    .reverse,
                    .front {
                        width: 100%;
                        position: relative;

                        input {
                            position: absolute;
                            display: inline-block;
                            width: 100%;
                            height: 100%;
                            opacity: 0;
                        }

                        img {
                            width: 100%;
                            height: 85px;
                            object-fit: contain;
                        }
                    }

                    span {
                        color: #9f9f9f;
                        margin-top: 5px;
                    }
                }
            }

            .warning {
                display: flex;
                align-items: center;
                margin-top: 15px;

                img {
                    margin-right: 5px;
                    width: 12px;
                }
            }
        }
    }

    .done {
        background-color: #f62221;
        background-clip: border-box;
        color: white;
        height: 40px;
        border-radius: 20px;
        text-align: center;
        line-height: 40px;
        position: absolute;
        bottom: 10px;
        width: 345px;
        left: 50%;
        transform: translateX(-50%);
    }
}
</style>